Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sadache committed Jul 30, 2012
1 parent ace3566 commit c9a6981
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions playapp/app/controllers/Application.scala
Expand Up @@ -28,14 +28,14 @@ object Application extends Controller {
val chunker = Enumeratee.grouped(Traversable.take[Array[Double]](5000) &>> Iteratee.consume())

val chunkedAudioStream = rawStream &> chunker &> audioEncoder
val (sharedChunkedAudioStream, _) = broadcast(chunkedAudioStream)
val (sharedChunkedAudioStream, _) = Concurrent.broadcast(chunkedAudioStream)

def index = Action {
Ok(views.html.index())
}

def stream = Action {
Ok.stream(audioHeader >>> sharedChunkedAudioStream).
Ok.stream(audioHeader >>> sharedChunkedAudioStream &> Concurrent.dropInputIfNotReady(10)).
withHeaders( (CONTENT_TYPE, audio.contentType),
(CACHE_CONTROL, "no-cache") )
}
Expand Down Expand Up @@ -64,7 +64,4 @@ object Application extends Controller {
Ok(toJson(Map("result" -> "Wave changed")))
}

// temporary bugfixed copy/paste of Concurrent.scala:366
def broadcast[E](e: Enumerator[E],interestIsDownToZero: => Unit = ()): (Enumerator[E],Broadcaster) = {val h = Concurrent.hub(e,() => interestIsDownToZero); (h.getPatchCord(),h) }

}
2 changes: 1 addition & 1 deletion playapp/app/encoders/MonoWaveEncoder.scala
Expand Up @@ -33,7 +33,7 @@ case class MonoWaveEncoder (

def encodeData(data: Array[Double]): Array[Byte] = {
data flatMap { d =>
ShortLittleBytes(math.max(-1, math.min(d, 1))*0x7fff toShort)
ShortLittleBytes(math.max(-1.0, math.min(d, 1.0))*0x7fff toShort)
}
}

Expand Down

0 comments on commit c9a6981

Please sign in to comment.