Merge branch 'master' into clangen/upstream-pdcurses

This commit is contained in:
casey langen 2020-02-29 23:28:15 -08:00
commit f7039b9a25
6 changed files with 66 additions and 20 deletions

View File

@ -58,8 +58,8 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
implementation 'com.google.firebase:firebase-analytics:17.2.2' implementation 'com.google.firebase:firebase-analytics:17.2.3'
implementation 'com.google.firebase:firebase-core:17.2.2' implementation 'com.google.firebase:firebase-core:17.2.3'
implementation(name:'android-taskrunner-0.5', ext:'aar') implementation(name:'android-taskrunner-0.5', ext:'aar')
implementation(name:'exoplayer-extension-flac-release-v2', ext:'aar') implementation(name:'exoplayer-extension-flac-release-v2', ext:'aar')
@ -67,8 +67,8 @@ dependencies {
implementation 'org.slf4j:slf4j-android:1.7.21' implementation 'org.slf4j:slf4j-android:1.7.21'
implementation "androidx.room:room-runtime:2.2.3" implementation "androidx.room:room-runtime:2.2.4"
kapt "androidx.room:room-compiler:2.2.3" kapt "androidx.room:room-compiler:2.2.4"
implementation "androidx.lifecycle:lifecycle-runtime:2.2.0" implementation "androidx.lifecycle:lifecycle-runtime:2.2.0"
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
@ -86,7 +86,7 @@ dependencies {
implementation 'io.reactivex.rxjava2:rxjava:2.2.16' implementation 'io.reactivex.rxjava2:rxjava:2.2.16'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxkotlin:2.4.0' implementation 'io.reactivex.rxjava2:rxkotlin:2.4.0'
implementation 'com.google.android.exoplayer:exoplayer:2.11.2' implementation 'com.google.android.exoplayer:exoplayer:2.11.3'
implementation 'com.google.android.exoplayer:extension-okhttp:2.11.2' implementation 'com.google.android.exoplayer:extension-okhttp:2.11.2'
implementation 'com.simplecityapps:recyclerview-fastscroll:2.0.0' implementation 'com.simplecityapps:recyclerview-fastscroll:2.0.0'
implementation 'com.github.wooplr:Spotlight:1.3' implementation 'com.github.wooplr:Spotlight:1.3'
@ -94,7 +94,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.2.0-alpha04' implementation 'com.google.android.material:material:1.2.0-alpha05'
implementation 'androidx.media:media:1.1.0' implementation 'androidx.media:media:1.1.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'

View File

@ -254,9 +254,17 @@ class StreamingPlaybackService(context: Context) : IPlaybackService {
if (requestAudioFocus()) { if (requestAudioFocus()) {
cancelScheduledPausedSleep() cancelScheduledPausedSleep()
if (playContext.currentPlayer != null) { playContext.currentPlayer?.let { player ->
if (playContext.currentPlayer?.position ?: 0 > PREV_TRACK_GRACE_PERIOD_MILLIS) { if (player.position > PREV_TRACK_GRACE_PERIOD_MILLIS) {
playContext.currentPlayer?.position = 0 /* if it takes too long to start up a player instance (e.g. we have to wait
for the backend to transcode, sometimes the duration is a negative number.
in that case we'll do this more heavy-weight reset */
if (player.duration <= PREV_TRACK_GRACE_PERIOD_MILLIS) {
playAt(queuePosition)
}
else {
player.position = 0
}
return return
} }
} }

View File

@ -8,7 +8,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.3' classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3' classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.2' classpath 'io.fabric.tools:gradle:1.31.2'

View File

@ -1,6 +1,6 @@
#Mon Aug 26 14:58:27 PDT 2019 #Sat Feb 29 11:27:33 PST 2020
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

View File

@ -294,9 +294,9 @@ bool HttpServer::Start() {
httpServer = MHD_start_daemon( httpServer = MHD_start_daemon(
#if MHD_VERSION >= 0x00095300 #if MHD_VERSION >= 0x00095300
MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | ipVersion, MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION | ipVersion,
#else #else
MHD_USE_SELECT_INTERNALLY | ipVersion, MHD_USE_SELECT_INTERNALLY | MHD_USE_THREAD_PER_CONNECTION | ipVersion,
#endif #endif
context.prefs->GetInt(prefs::http_server_port.c_str(), defaults::http_server_port), context.prefs->GetInt(prefs::http_server_port.c_str(), defaults::http_server_port),
nullptr, nullptr,

View File

@ -39,10 +39,16 @@
#include "Util.h" #include "Util.h"
#include <core/sdk/IBlockingEncoder.h> #include <core/sdk/IBlockingEncoder.h>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <thread>
#include <set>
using namespace musik::core::sdk; using namespace musik::core::sdk;
using namespace boost::filesystem; using namespace boost::filesystem;
std::mutex transcoderMutex;
std::condition_variable waitForTranscode;
std::set<std::string> runningBlockingTranscoders;
static IEncoder* getEncoder(Context& context, const std::string& format) { static IEncoder* getEncoder(Context& context, const std::string& format) {
std::string extension = "." + format; std::string extension = "." + format;
return context.environment->GetEncoder(extension.c_str()); return context.environment->GetEncoder(extension.c_str());
@ -267,13 +273,45 @@ IDataStream* Transcoder::TranscodeAndWait(
return context.environment->GetDataStream(uri.c_str(), OpenFlags::Read); return context.environment->GetDataStream(uri.c_str(), OpenFlags::Read);
} }
else { else {
IBlockingEncoder* dataStreamEncoder = dynamic_cast<IBlockingEncoder*>(encoder); IBlockingEncoder* blockingEncoder = dynamic_cast<IBlockingEncoder*>(encoder);
if (dataStreamEncoder) { if (blockingEncoder) {
BlockingTranscoder blockingTranscoder( bool waitForExisting = false;
context, dataStreamEncoder, uri, tempFilename, expectedFilename, bitrate); {
/* see if there's already a blocking transcoder running for the specified
uri. if there is, wait for it to complete. if there's not, add it to the
running set */
std::unique_lock<std::mutex> lock(transcoderMutex);
waitForExisting = runningBlockingTranscoders.find(uri) != runningBlockingTranscoders.end();
if (waitForExisting) {
while (runningBlockingTranscoders.find(uri) != runningBlockingTranscoders.end()) {
waitForTranscode.wait(lock);
}
}
else {
runningBlockingTranscoders.insert(uri);
}
}
if (!blockingTranscoder.Transcode()) { if (!waitForExisting) {
return nullptr; BlockingTranscoder blockingTranscoder(
context, blockingEncoder, uri, tempFilename, expectedFilename, bitrate);
bool success = blockingTranscoder.Transcode();
{
/* let anyone else waiting for a resource to be transcoding that we
finished. */
std::unique_lock<std::mutex> lock(transcoderMutex);
auto it = runningBlockingTranscoders.find(uri);
if (it != runningBlockingTranscoders.end()) {
runningBlockingTranscoders.erase(it);
}
waitForTranscode.notify_all();
}
if (!success) {
return nullptr;
}
} }
} }