Small videoplayer sample fix.

This commit is contained in:
Nikolay Igotti
2017-12-25 16:38:30 +03:00
parent 1a59a84863
commit 0fcab4d396
3 changed files with 37 additions and 8 deletions
@@ -207,8 +207,6 @@ private class AudioDecoder(
}
with (audioCodecContext) {
var inputChannelLayout = if (channel_layout != 0L)
channel_layout else av_get_default_channel_layout(audioCodecContext.channels)
setResampleOpt("in_channel_layout", channel_layout.narrow())
setResampleOpt("out_channel_layout", output.channelLayout)
setResampleOpt("in_sample_rate", sample_rate)
@@ -1,3 +1,18 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
data class Dimensions(val w: Int, val h: Int) {
operator fun minus(other: Dimensions) = Dimensions(w - other.w, h - other.h)
@@ -1,3 +1,18 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import kotlinx.cinterop.*
@@ -38,11 +53,10 @@ abstract class DisposableContainer : Disposable {
throw e
}
// TODO: It shall be inline, but crashes backend
fun <T> disposable(
inline fun <T> disposable(
message: String = "disposable",
create: () -> T?,
dispose: (T) -> Unit
crossinline dispose: (T) -> Unit
): T =
tryConstruct {
create()?.also {
@@ -50,13 +64,15 @@ abstract class DisposableContainer : Disposable {
} ?: throw Error(message)
}
// TODO: It shall be inline, but crashes backend
fun <T : Disposable> disposable(create: () -> T): T =
inline fun <T : Disposable> disposable(create: () -> T): T =
disposable(
create = create,
dispose = { it.dispose() })
fun <T : CPointed> sdlDisposable(message: String, ptr: CPointer<T>?, dispose: (CPointer<T>) -> Unit): CPointer<T> =
inline fun <T : CPointed> sdlDisposable(
message: String,
ptr: CPointer<T>?,
crossinline dispose: (CPointer<T>) -> Unit): CPointer<T> =
disposable(
create = { ptr ?: throwSDLError(message) },
dispose = dispose)